package com.huhu.entity;

import com.huhu.common.util.DataUt;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 *
 *
 * @version 1.0 2016-09-15
 */
public class User  implements Serializable{
    private Integer userId;

    private String userName;

    private String password;

    private String salt;

    //一个用户具有多个角色
    private List<Role> roleList;

    private Set<String> allRole;

    private Set<String> allPermission;

    //获取用户角色名称的Set
    public Set<String> getRolesName(){
        List<Role> roleList = getRoleList();

        Set<String> rolesNameSet = new HashSet<String>();
        if (DataUt.isNotEmpty(roleList)) {
            for (Role role : roleList) {
                rolesNameSet.add(role.getRoleName());
            }
        }
        return rolesNameSet;
    }



    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Set<String> getAllRole() {
        return allRole;
    }

    public void setAllRole(Set<String> allRole) {
        this.allRole = allRole;
    }

    public Set<String> getAllPermission() {
        return allPermission;
    }

    public void setAllPermission(Set<String> allPermission) {
        this.allPermission = allPermission;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }
}